#pragma
#include"RBTree.h"

namespace my_Set
{
	template<class K>
	class Set
	{
		//º
		struct SetKeyOfT
		{
			const K& operator()(const K& key)
			{
				return key;
			}
		};

	public:
		//
		typedef typename RBTree<K, K, SetKeyOfT>::iterator iterator;
		typedef typename RBTree<K, K, SetKeyOfT>::const_iterator const_iterator;

		iterator begin()
		{
			return _t.begin();
		}
		iterator end()
		{
			return _t.end();
		}

		pair<iterator, bool> insert(const K& key)
		{
			return _t.Insert(key);
		}

		bool find(const K& key)
		{
			return _t.Find(key);
		}

	private:
		RBTree< K, K, SetKeyOfT> _t;
	};

	void testSet1()
	{
		Set<int> s;
		int arr[]{ 16, 3, 7, 11, 9, 26, 18, 14, 15 };

		for (auto num : arr)
		{
			s.insert(num);
		}

		Set<int>::iterator it = s.begin();
		while (it != s.end())
		{
			cout << *it << " ";
			//*it = 1;
			++it;
		}
		cout << endl;


		for (auto n : s)
		{
			cout << n << " ";
		}
		cout << endl;
	}
}